home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / install / FileZilla Server.nsi next >
Text File  |  2012-02-22  |  21KB  |  642 lines

  1. ;FileZilla Server Setup script
  2. ;written by Tim Kosse (Tim.Kosse@gmx.de)
  3. ;Based on
  4. ;NSIS Modern User Interface version 1.6
  5. ;Basic Example Script
  6. ;Written by Joost Verburg
  7.  
  8. ;Set compressor before outputting anything
  9. SetCompressor /SOLID LZMA
  10.  
  11. ;--------------------------------
  12. ;Include Modern UI
  13.  
  14.   !include "MUI.nsh"
  15.  
  16. ;--------------------------------
  17. ;Product Info
  18.  
  19.   !define PRODUCT_NAME    "FileZilla Server"
  20.   !define VERSION_MAJOR   "0"
  21.   !define VERSION_MINOR   "9"
  22.   !define VERSION_MICRO   "41"
  23.   !define VERSION_NANO    "0"
  24.   !define PRODUCT_VERSION "beta ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}"
  25.   !define VERSION_FULL    "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_NANO}"
  26.   !define PUBLISHER       "FileZilla Project"
  27.   !define WEBSITE_URL     "http://filezilla-project.org/"
  28.   !define PRODUCT_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  29.   Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  30.  
  31. ;--------------------------------
  32. ;Installer's VersionInfo
  33.  
  34.   VIProductVersion                   "${VERSION_FULL}"
  35.   VIAddVersionKey "CompanyName"      "${PUBLISHER}"
  36.   VIAddVersionKey "ProductName"      "${PRODUCT_NAME}" 
  37.   VIAddVersionKey "ProductVersion"   "${PRODUCT_VERSION}"
  38.   VIAddVersionKey "FileDescription"  "${PRODUCT_NAME}"
  39.   VIAddVersionKey "FileVersion"      "${PRODUCT_VERSION}"
  40.   VIAddVersionKey "LegalCopyright"   "${PUBLISHER}"
  41.   VIAddVersionKey "OriginalFilename" "FileZilla_Server-${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_MICRO}.exe"
  42.  
  43. ;StartOptions Page strings
  44. LangString StartOptionsTitle ${LANG_ENGLISH} ": Server startup settings"
  45.  
  46. ;--------------------------------
  47. ;Modern UI Configuration
  48.  
  49.   !define MUI_ABORTWARNING
  50.  
  51.   !define MUI_ICON "..\res\filezilla server.ico"
  52.   !define MUI_UNICON "uninstall.ico"
  53.  
  54. ;--------------------------------
  55. ;Pages
  56.  
  57.   !insertmacro MUI_PAGE_LICENSE "..\..\license.txt"
  58.   !insertmacro MUI_PAGE_COMPONENTS
  59.   !insertmacro MUI_PAGE_DIRECTORY
  60.   Page custom StartOptions
  61.   Page custom InterfaceOptions
  62.   !insertmacro MUI_PAGE_INSTFILES
  63.  
  64.   !insertmacro MUI_UNPAGE_CONFIRM
  65.   !insertmacro MUI_UNPAGE_INSTFILES
  66.  
  67. ;--------------------------------
  68. ;Languages
  69.  
  70.   !insertmacro MUI_LANGUAGE "English"
  71.  
  72. ;--------------------------------
  73. ;More
  74.  
  75.   ;General
  76.   OutFile "../../FileZilla_Server-${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_MICRO}.exe"
  77.  
  78.   ;Installation types
  79.   InstType "Standard"
  80.   InstType "Full"
  81.   InstType "Service only"
  82.   InstType "Interface only"
  83.  
  84.   ;Descriptions
  85.   LangString DESC_SecFileZillaServer ${LANG_ENGLISH} "Copy FileZilla Server to the application folder."
  86.   LangString DESC_SecFileZillaServerInterface ${LANG_ENGLISH} "Copy the administration interface to the application folder."
  87.   LangString DESC_SecSourceCode ${LANG_ENGLISH} "Copy the source code of FileZilla Server to the application folder"
  88.   LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create shortcuts to FileZilla Server in the Start Menu"
  89.   LangString DESC_SecDesktopIcon ${LANG_ENGLISH} "Create an Icon on the desktop for quick access to the administration interface"
  90.  
  91.   ;Folder-selection page
  92.   InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
  93.   InstallDirRegKey HKLM "${PRODUCT_UNINSTALL}" "UninstallString"
  94.  
  95.   ShowInstDetails show
  96.  
  97.   RequestExecutionLevel admin
  98.  
  99. ;--------------------------------
  100. ;Reserve Files
  101.  
  102.   ;Things that need to be extracted on first (keep these lines before any File command!)
  103.   ;Only useful for BZIP2 compression
  104.  
  105.   ReserveFile "StartupOptions.ini"
  106.   ReserveFile "InterfaceOptions.ini"
  107.   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  108.  
  109. ;--------------------------------
  110. ;Installer Sections
  111.  
  112. Var GetInstalledSize.total
  113.  
  114. Section "-default files"
  115.   SectionIn 1 2 3 4
  116.  
  117.   ; Set output path to the installation directory.
  118.   SetOutPath $INSTDIR
  119.  
  120.   ; Put file there
  121.   File "libeay32.dll"
  122.   File "ssleay32.dll"
  123.   File "..\..\readme.htm"
  124.   File "..\..\legal.htm"
  125.   File "..\..\license.txt"
  126.  
  127.   ; Write the uninstall keys for Windows
  128.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "DisplayName"     "FileZilla Server"
  129.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "DisplayIcon"     "$INSTDIR\FileZilla server.exe"
  130.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "DisplayVersion"  "${PRODUCT_VERSION}"
  131.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "HelpLink"        "${WEBSITE_URL}"
  132.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "InstallLocation" "$INSTDIR"
  133.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "URLInfoAbout"    "${WEBSITE_URL}"
  134.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "URLUpdateInfo"   "${WEBSITE_URL}"
  135.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "UninstallString" "$INSTDIR\uninstall.exe"
  136.   WriteRegStr   HKLM "${PRODUCT_UNINSTALL}" "Publisher"       "${PUBLISHER}"
  137.   WriteRegDWORD HKLM "${PRODUCT_UNINSTALL}" "VersionMajor"    "${VERSION_MAJOR}"
  138.   WriteRegDWORD HKLM "${PRODUCT_UNINSTALL}" "VersionMinor"    "${VERSION_MINOR}"
  139.   WriteRegDWORD HKLM "${PRODUCT_UNINSTALL}" "NoModify"        "1"
  140.   WriteRegDWORD HKLM "${PRODUCT_UNINSTALL}" "NoRepair"        "1"
  141.  
  142.   Call GetInstalledSize
  143.   WriteRegDWORD HKLM "${PRODUCT_UNINSTALL}" "EstimatedSize"  "$GetInstalledSize.total" ; Create/Write the reg key with the dword value
  144.  
  145.   WriteUninstaller "$INSTDIR\Uninstall.exe"
  146.  
  147. SectionEnd
  148.  
  149. Section "FileZilla Server (Service)" SecFileZillaServer
  150.   SectionIn 1 2 3
  151.   ; Set output path to the installation directory.
  152.   SetOutPath $INSTDIR
  153.  
  154.   IfFileExists "$INSTDIR\FileZilla Server.exe" found
  155.  
  156.   File "..\Release\FileZilla Server.exe"
  157.  
  158.   DetailPrint "Stopping service..."
  159.   ExecWait '"$INSTDIR\FileZilla Server.exe" /stop'
  160.   ExecWait '"$INSTDIR\FileZilla Server.exe" /compat /stop'
  161.   Sleep 500
  162.   Push "FileZilla Server Helper Window"
  163.   call CloseWindowByName
  164.   DetailPrint "Uninstalling service..."
  165.   ExecWait '"$INSTDIR\FileZilla Server.exe" /uninstall'
  166.   Sleep 500
  167.   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCT_NAME}"
  168.   DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCT_NAME}"
  169.   goto copy_main_done
  170.  found:
  171.   GetTempFileName $R1
  172.   File /oname=$R1 "..\Release\FileZilla Server.exe"
  173.   DetailPrint "Stopping service..."
  174.   ExecWait '"$R1" /stop'
  175.   ExecWait '"$R1" /compat /stop'
  176.   Sleep 500
  177.   Push "FileZilla Server Helper Window"
  178.   call CloseWindowByName
  179.   DetailPrint "Uninstalling service..."
  180.   ExecWait '"$R1" /uninstall'
  181.   Sleep 500
  182.   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCT_NAME}"
  183.   DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCT_NAME}"
  184.   Delete "$INSTDIR\FileZilla Server.exe"
  185.   Rename $R1 "$INSTDIR\FileZilla Server.exe"
  186.  copy_main_done:
  187.  
  188.   ; Put file there
  189.   File "..\GFtp\Release\FzGss.dll"
  190. SectionEnd
  191.  
  192. Section "Administration interface" SecFileZillaServerInterface
  193.   SectionIn 1 2 4
  194.  
  195.   ; Set output path to the installation directory.
  196.   SetOutPath $INSTDIR
  197.  
  198.   ; Stopping interface
  199.   DetailPrint "Closing interface..."
  200.   Push "FileZilla Server Main Window"
  201.   Call CloseWindowByName
  202.  
  203.   File "..\Interface\Release\FileZilla Server Interface.exe"
  204.  
  205. SectionEnd
  206.  
  207. Section "Source Code" SecSourceCode
  208. SectionIn 2
  209.   SetOutPath "$INSTDIR\source"
  210.   File "..\*.cpp"
  211.   File "..\*.h"
  212.   File "..\FileZilla Server.sln"
  213.   File "..\FileZilla Server.vcproj"
  214.   File "..\FileZilla Server.rc"
  215.   SetOutPath "$INSTDIR\source\res"
  216.   File "..\res\*.ico"
  217.   SetOutPath "$INSTDIR\source\misc"
  218.   File "..\misc\*.h"
  219.   File "..\misc\*.cpp"
  220.   SetOutPath "$INSTDIR\source\hash_algorithms"
  221.   File "..\hash_algorithms\*.h"
  222.   File "..\hash_algorithms\*.c"
  223.   SetOutPath "$INSTDIR\source\interface"
  224.   File "..\interface\*.cpp"
  225.   File "..\interface\*.h"
  226.   File "..\interface\FileZilla Server Interface.vcproj"
  227.   File "..\interface\FileZilla Server.rc"
  228.   SetOutPath "$INSTDIR\source\interface\res"
  229.   File "..\interface\res\*.bmp"
  230.   File "..\interface\res\*.ico"
  231.   File "..\interface\res\*.rc2"
  232.   File "..\interface\res\manifest.xml"
  233.   SetOutPath "$INSTDIR\source\interface\misc"
  234.   File "..\interface\misc\*.h"
  235.   File "..\interface\misc\*.cpp"
  236.   SetOutPath "$INSTDIR\source\install"
  237.   File "FileZilla Server.nsi"
  238.   File "StartupOptions.ini"
  239.   File "InterfaceOptions.ini"
  240.   File "uninstall.ico"
  241.   SetOutPath "$INSTDIR\source\includes\openssl"
  242.   File "..\includes\openssl\*.h"
  243.   SetOutPath "$INSTDIR\source\tinyxml"
  244.   File "..\tinyxml\*.h"
  245.   File "..\tinyxml\*.cpp"
  246. SectionEnd
  247.  
  248. ; optional section
  249. Section "Start Menu Shortcuts" SecStartMenu
  250. SectionIn 1 2 3 4
  251.   SetShellVarContext all
  252.  
  253.   CreateDirectory "$SMPROGRAMS\FileZilla Server"
  254.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  255.  
  256.   SectionGetFlags 1 $R0
  257.   IntOp $R0 $R0 & 1
  258.   IntCmp $R0 0 done_service_startmenu
  259.  
  260.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "StartupOptions.ini" "Field 2" "State"
  261.   StrCmp $R0 "Do not install as service, start server automatically (not recommended)" shortcutcompat
  262.  
  263.   ;NT service shortcuts
  264.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Start FileZilla Server.lnk" "$INSTDIR\FileZilla Server.exe" "/start" "$INSTDIR\FileZilla Server.exe" 0
  265.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Stop FileZilla Server.lnk" "$INSTDIR\FileZilla Server.exe" "/stop" "$INSTDIR\FileZilla Server.exe" 0
  266.   goto done_service_startmenu
  267.  shortcutcompat:
  268.   ;Compat mode
  269.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Start FileZilla Server.lnk" "$INSTDIR\FileZilla Server.exe" "/compat /start" "$INSTDIR\FileZilla Server.exe" 0
  270.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Stop FileZilla Server.lnk" "$INSTDIR\FileZilla Server.exe" "/compat /stop" "$INSTDIR\FileZilla Server.exe" 0
  271.  
  272.  done_service_startmenu:
  273.  
  274.   SectionGetFlags 2 $R0
  275.   IntOp $R0 $R0 & 1
  276.   IntCmp $R0 0 done_interface_startmenu
  277.  
  278.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\FileZilla Server Interface.lnk" "$INSTDIR\FileZilla Server Interface.exe" "" "$INSTDIR\FileZilla Server Interface.exe" 0
  279.  
  280.  done_interface_startmenu:
  281.  
  282.   SectionGetFlags 3 $R0
  283.   IntOp $R0 $R0 & 1
  284.   IntCmp $R0 0 done_source_startmenu
  285.  
  286.   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\FileZilla Server Source Project.lnk" "$INSTDIR\source\FileZilla Server.sln" "" "$INSTDIR\source\FileZilla Server.sln" 0
  287.  
  288.  done_source_startmenu:
  289.  
  290. SectionEnd
  291.  
  292. Section "Desktop Icon" SecDesktopIcon
  293. SectionIn 1 2 4
  294.  
  295.   SectionGetFlags 2 $R0
  296.   IntOp $R0 $R0 & 1
  297.   IntCmp $R0 0 noDesktopIcon
  298.  
  299.   CreateShortCut "$DESKTOP\FileZilla Server Interface.lnk" "$INSTDIR\FileZilla Server Interface.exe" "" "$INSTDIR\FileZilla Server Interface.exe" 0
  300.  
  301.  noDesktopIcon:
  302.  
  303. SectionEnd
  304.  
  305. Section "-PostInst"
  306.  
  307.   ; Write the installation path into the registry
  308.   WriteRegStr HKCU "SOFTWARE\${PRODUCT_NAME}" "Install_Dir" "$INSTDIR"
  309.   WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Install_Dir" "$INSTDIR"
  310.  
  311.   SectionGetFlags 1 $R0
  312.   IntOp $R0 $R0 & 1
  313.   IntCmp $R0 0 NoSetAdminPort
  314.  
  315.   ;Set Adminport
  316.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "StartupOptions.ini" "Field 4" "State"
  317.   ExecWait '"$INSTDIR\FileZilla Server.exe" /adminport $R0'
  318.  
  319.   SectionGetFlags 2 $R0
  320.   IntOp $R0 $R0 & 1
  321.   IntCmp $R0 0 NoSetAdminPort
  322.  
  323.   ExecWait '"$INSTDIR\FileZilla Server Interface.exe" /adminport $R0'
  324.  NoSetAdminPort:
  325.  
  326.   SectionGetFlags 1 $R0
  327.   IntOp $R0 $R0 & 1
  328.   IntCmp $R0 0 done
  329.  
  330.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "StartupOptions.ini" "Field 2" "State"
  331.   StrCmp $R0 "Do not install as service, start server automatically (not recommended)" Install_Standard_Auto
  332.   DetailPrint "Installing Service..."
  333.   StrCmp $R0 "Install as service, started manually" Install_AsService_Manual
  334.  
  335.   ExecWait '"$INSTDIR\FileZilla Server.exe" /install auto'
  336.   goto done
  337.  Install_AsService_Manual:
  338.   ExecWait '"$INSTDIR\FileZilla Server.exe" /install'
  339.   goto done
  340.  Install_Standard_Auto:
  341.   DetailPrint "Put FileZilla Server into registry..."
  342.   ClearErrors
  343.   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server" '"$INSTDIR\FileZilla Server.exe" /compat /start'
  344.   IfErrors Install_Standard_Auto_CU
  345.   goto done
  346.  Install_Standard_Auto_CU:
  347.   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server" '"$INSTDIR\FileZilla Server.exe" /compat /start'
  348.  done:
  349.  
  350.   SectionGetFlags 2 $R0
  351.   IntOp $R0 $R0 & 1
  352.   IntCmp $R0 0 interface_done
  353.  
  354.   ;Write interface startup settings
  355.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 $3 "Field 2" "State"
  356.   StrCmp $R0 "Start manually" interface_done
  357.   DetailPrint "Put FileZilla Server Interface into registry..."
  358.   StrCmp $R0 "Start if user logs on, apply only to current user" interface_cu
  359.   ClearErrors
  360.   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server Interface" '"$INSTDIR\FileZilla Server Interface.exe"'
  361.   IfErrors interface_cu
  362.   goto interface_done
  363.  interface_cu:
  364.   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server Interface" '"$INSTDIR\FileZilla Server Interface.exe"'
  365.  interface_done:
  366.  
  367. SectionEnd
  368.  
  369. ;--------------------------------
  370. ;Descriptions
  371.  
  372. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  373.   !insertmacro MUI_DESCRIPTION_TEXT ${SecFileZillaServer} $(DESC_SecFileZillaServer)
  374.   !insertmacro MUI_DESCRIPTION_TEXT ${SecFileZillaServerInterface} $(DESC_SecFileZillaServerInterface)
  375.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSourceCode} $(DESC_SecSourceCode)
  376.   !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu)
  377.   !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopIcon} $(DESC_SecDesktopIcon)
  378. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  379.  
  380. ;--------------------------------
  381. ;Installer Functions
  382.  
  383. Function .onInit
  384.  
  385.   ;Detect Windows type (NT or 9x)
  386.  
  387.   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  388.   StrCmp $R0 "" 0 detection_NT
  389.  
  390.   ; we are not NT.
  391.   MessageBox MB_OK|MB_ICONSTOP "FileZilla Server does not support Windows 95/98/ME"
  392.   Abort
  393.   
  394.  detection_NT:
  395.  
  396.   ;Extract InstallOptions INI Files
  397.   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "StartupOptions.ini"
  398.  
  399.   ;Extract InstallOptions INI Files
  400.   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "InterfaceOptions.ini"
  401.   strcpy $3 "InterfaceOptions.ini"
  402.  
  403. FunctionEnd
  404.  
  405. LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Startup settings"
  406. LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "Select startup behaviour for FileZilla Server"
  407.  
  408. Function StartOptions
  409.  
  410.   IfSilent DoneServerStartOptions
  411.  
  412.   SectionGetFlags 1 $R0
  413.   IntOp $R0 $R0 & 1
  414.   IntCmp $R0 0 DoneServerStartOptions
  415.  
  416.   SectionGetFlags 2 $R0
  417.   IntOp $R0 $R0 & 1
  418.   IntCmp $R0 1 ChangeNextTextToNext
  419.   !insertmacro MUI_INSTALLOPTIONS_WRITE "StartupOptions.ini" "Settings" "NextButtonText" "&Install"
  420.   goto DoneChangeNextText
  421.  ChangeNextTextToNext:
  422.   !insertmacro MUI_INSTALLOPTIONS_WRITE "StartupOptions.ini" "Settings" "NextButtonText" "&Next"
  423.  DoneChangeNextText:
  424.  
  425.  
  426.   !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
  427.   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "StartupOptions.ini"
  428.  
  429.  DoneServerStartOptions:
  430.  
  431. FunctionEnd
  432.  
  433. Function InterfaceOptions
  434.  
  435.   IfSilent DoneInterfaceStartOptions
  436.  
  437.   SectionGetFlags 2 $R0
  438.   IntOp $R0 $R0 & 1
  439.   IntCmp $R0 0 DoneInterfaceStartOptions
  440.  
  441.   !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
  442.   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "InterfaceOptions.ini"
  443.  
  444.  DoneInterfaceStartOptions:
  445.  
  446. FunctionEnd
  447.  
  448. Function .onInstSuccess
  449.  
  450.   SectionGetFlags 1 $R0
  451.   IntOp $R0 $R0 & 1
  452.   IntCmp $R0 0 startserverend
  453.  
  454.  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "StartupOptions.ini" "Field 5" "State"
  455.  
  456.   strcmp $R0 "0" startserverend
  457.  
  458.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "StartupOptions.ini" "Field 2" "State"
  459.   StrCmp $R0 "Do not install as service, start server automatically (not recommended)" startservercompat
  460.  
  461.   Exec '"$INSTDIR\FileZilla Server.exe" /start'
  462.   goto startserverend
  463.  startservercompat:
  464.   Exec '"$INSTDIR\FileZilla Server.exe" /compat /start'
  465.  startserverend:
  466.  
  467.   SectionGetFlags 2 $R0
  468.   IntOp $R0 $R0 & 1
  469.   IntCmp $R0 0 NoStartInterface
  470.  
  471.   !insertmacro MUI_INSTALLOPTIONS_READ $R0 $3 "Field 3" "State"
  472.   strcmp $R0 "0" NoStartInterface
  473.   Exec '"$INSTDIR\FileZilla Server Interface.exe"'
  474.  NoStartInterface:
  475. FunctionEnd
  476.  
  477. Function CloseWindowByName
  478.   Exch $R1
  479.  closewindow_start:
  480.   FindWindow $R0 $R1
  481.   strcmp $R0 0 closewindow_end
  482.   SendMessage $R0 ${WM_CLOSE} 0 0
  483.   Sleep 500
  484.   goto closewindow_start
  485.  closewindow_end:
  486.   Pop $R1
  487. FunctionEnd
  488.  
  489. Var prevSel
  490. Function .onSelChange
  491.  
  492.   SectionGetFlags 1 $R0
  493.   SectionGetFlags 2 $R1
  494.  
  495.   IntOp $R2 $R0 & 1
  496.   IntOp $R2 $R2 | $prevSel
  497.   IntCmp $R2 1 +2
  498.     IntOp $R1 $R1 | 1
  499.  
  500.   IntOp $R2 $R1 & 1
  501.   IntCmp $R2 1 +2
  502.     IntOp $R0 $R0 | 1
  503.  
  504.   SectionSetFlags 1 $R0
  505.   SectionSetFlags 2 $R1
  506.  
  507.   IntOp $prevSel $R1 & 1
  508.  
  509. FunctionEnd
  510.  
  511. Function GetInstalledSize
  512.   Push $0
  513.   Push $1
  514.   StrCpy $GetInstalledSize.total 0
  515.   ${ForEach} $1 0 256 + 1
  516.     ${if} ${SectionIsSelected} $1
  517.       SectionGetSize $1 $0
  518.       IntOp $GetInstalledSize.total $GetInstalledSize.total + $0
  519.     ${Endif}
  520.   ${Next}
  521.   Pop $1
  522.   Pop $0
  523.   IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total
  524.   Push $GetInstalledSize.total
  525. FunctionEnd
  526.  
  527. ;--------------------------------
  528. ;Uninstaller Section
  529.  
  530. Section "Uninstall"
  531.   SetShellvarContext all
  532.  
  533.   ; Stopping and uninstalling service
  534.   DetailPrint "Stopping service..."
  535.   ExecWait '"$INSTDIR\FileZilla Server.exe" /stop'
  536.   Sleep 500
  537.   Push "FileZilla Server Helper Window"
  538.   Call un.CloseWindowByName
  539.   DetailPrint "Uninstalling service..."
  540.   ExecWait '"$INSTDIR\FileZilla Server.exe" /uninstall'
  541.   Sleep 500
  542.  
  543.   ; Stopping interface
  544.   DetailPrint "Closing interface..."
  545.   Push "FileZilla Server Main Window"
  546.   Call un.CloseWindowByName
  547.  
  548.   ; remove registry keys
  549.   DeleteRegValue HKCU "Software\${PRODUCT_NAME}" "Install_Dir"
  550.   DeleteRegValue HKLM "Software\${PRODUCT_NAME}" "Install_Dir"
  551.   DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}"
  552.   DeleteRegKey /ifempty HKLM "Software\${PRODUCT_NAME}"
  553.   MessageBox MB_YESNO "Delete settings?" IDNO NoSettingsDelete
  554.   Delete "$INSTDIR\FileZilla Server.xml"
  555.   Delete "$INSTDIR\FileZilla Server Interface.xml"
  556.  NoSettingsDelete:
  557.   DeleteRegKey HKLM "${PRODUCT_UNINSTALL}"
  558.   ; remove files
  559.   Delete "$INSTDIR\FileZilla Server.exe"
  560.   Delete "$INSTDIR\FileZilla Server Interface.exe"
  561.   Delete "$INSTDIR\ssleay32.dll"
  562.   Delete "$INSTDIR\libeay32.dll"
  563.   Delete $INSTDIR\FzGss.dll
  564.   Delete $INSTDIR\license.txt
  565.   Delete $INSTDIR\readme.htm
  566.   Delete $INSTDIR\legal.htm
  567.   Delete $INSTDIR\source\*.cpp
  568.   Delete $INSTDIR\source\*.h
  569.   Delete "$INSTDIR\source\FileZilla Server.sln"
  570.   Delete "$INSTDIR\source\FileZilla Server.vcproj"
  571.   Delete "$INSTDIR\source\FileZilla Server.rc"
  572.   Delete $INSTDIR\source\res\*.ico
  573.   Delete $INSTDIR\source\res\*.bmp
  574.   Delete $INSTDIR\source\res\*.rc2
  575.   Delete $INSTDIR\source\misc\*.h
  576.   Delete $INSTDIR\source\misc\*.cpp
  577.   Delete $INSTDIR\source\hash_algorithms\*.h
  578.   Delete $INSTDIR\source\hash_algorithms\*.c
  579.   Delete $INSTDIR\source\interface\*.cpp
  580.   Delete $INSTDIR\source\interface\*.h
  581.   Delete "$INSTDIR\source\interface\FileZilla Server Interface.vcproj"
  582.   Delete "$INSTDIR\source\interface\FileZilla Server.rc"
  583.   Delete $INSTDIR\source\interface\res\*.ico
  584.   Delete $INSTDIR\source\interface\res\*.bmp
  585.   Delete $INSTDIR\source\interface\res\*.rc2
  586.   Delete $INSTDIR\source\interface\res\manifest.xml
  587.   Delete $INSTDIR\source\interface\misc\*.h
  588.   Delete $INSTDIR\source\interface\misc\*.cpp
  589.   Delete $INSTDIR\source\install\uninstall.ico
  590.   Delete "$INSTDIR\source\install\FileZilla Server.nsi"
  591.   Delete "$INSTDIR\source\install\StartupOptions.ini"
  592.   Delete "$INSTDIR\source\install\InterfaceOptions.ini"
  593.   Delete "$INSTDIR\source\includes\openssl\*.h"
  594.   Delete "$INSTDIR\source\tinyxml\*.h"
  595.   Delete "$INSTDIR\source\tinyxml\*.cpp"
  596.  
  597.   ; MUST REMOVE UNINSTALLER, too
  598.   Delete $INSTDIR\uninstall.exe
  599.  
  600.   ; remove shortcuts, if any.
  601.   Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
  602.   Delete "$DESKTOP\FileZilla Server Interface.lnk"
  603.   RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
  604.  
  605.   ; remove directories used.
  606.  
  607.   RMDir "$INSTDIR\source\res"
  608.   RMDir "$INSTDIR\source\misc"
  609.   RMDir "$INSTDIR\source\hash_algorithms"
  610.   RMDir "$INSTDIR\source\interface\res"
  611.   RMDir "$INSTDIR\source\interface\misc"
  612.   RMDir "$INSTDIR\source\interface"
  613.   RMDir "$INSTDIR\source\install"
  614.   RMDir "$INSTDIR\source\includes\openssl"
  615.   RMDir "$INSTDIR\source\includes"
  616.   RMDir "$INSTDIR\source\tinyxml"
  617.   RMDir "$INSTDIR\source"
  618.   RMDir "$INSTDIR"
  619.   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server"
  620.   DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server"
  621.   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server Interface"
  622.   DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "FileZilla Server Interface"
  623.  
  624.   RMDir "$INSTDIR"
  625.  
  626. SectionEnd
  627.  
  628. ;--------------------------------
  629. ;Uninstaller Functions
  630.  
  631. Function un.CloseWindowByName
  632.   Exch $R1
  633.  unclosewindow_start:
  634.   FindWindow $R0 $R1
  635.   strcmp $R0 0 unclosewindow_end
  636.   SendMessage $R0 ${WM_CLOSE} 0 0
  637.   Sleep 500
  638.   goto unclosewindow_start
  639.   Pop $R1
  640.  unclosewindow_end:
  641. FunctionEnd
  642.